<?php $manageStocks = mage::helper('AdvancedStock/Product_Base')->ManageStock($this->getProduct()->getId()); ?>

<input type="hidden" id="product_id" name="product_id" value="<?php echo $this->getProduct()->getId(); ?>">

<div class="entry-edit-head">
    <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Miscelaneous'); ?></h4>
</div>
<div class="entry-edit">
    <fieldset>
        <table cellspacing="0" class="form-list">
            <tr>
                <td width="150"><?php echo $this->__('Created at'); ?></td>
                <td class="input-ele" width="150">
                    <?php echo $this->getProduct()->getcreated_at(); ?>
                </td>
                <td width="150"><?php echo $this->__('Updated at'); ?></td>
                <td class="input-ele" width="150">
                    <?php echo $this->getProduct()->getupdated_at(); ?>
                </td>
            </tr>
        </table>
    </fieldset>
</div>

<table border="0" width="100%" border="0" cellpadding="0">
    <tr>
        <td width="70%">
            <div class="entry-edit-head">
                <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Stock settings'); ?></h4>
            </div>
            <div class="entry-edit">
                <fieldset>
                    <table cellspacing="0" class="form-list">
                        <tr>
                            <td width="100"><?php echo $this->__('Manage stocks'); ?></td>
                            <td class="input-ele" width="150">
                                <?php echo $this->getManageStockCombo('stocks[manage_stock]'); ?>
                            </td>
                            <td>
                                &nbsp;&nbsp;<?php echo $this->getUseDefaultCombo('stocks[use_config_manage_stock]', $this->useConfigManageStock(), 'stocks[manage_stock]'); ?>
                            </td>
                        </tr>
                        <tr>
                            <td width="100"><?php echo $this->__('Backorders'); ?></td>
                            <td class="input-ele">
                                <?php echo $this->getBackordersCombo('stocks[backorders]'); ?>
                            </td>
                            <td>
                                &nbsp;&nbsp;<?php echo $this->getUseDefaultCombo('stocks[use_config_backorders]', $this->useConfigBackorders(), 'stocks[backorders]'); ?>
                            </td>
                        </tr>
                        <tr>
                            <td width="100"><?php echo $this->__('Is in stock'); ?></td>
                            <td class="input-ele" width="150">
                                <?php echo $this->getIsInStockCombo('stocks[is_in_stock]'); ?>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </div>

        </td>
        <td width="30%">
        	<?php
        		//programmatically add block
                        $block = $this->getLayout()->createBlock('core/template');
                        $block->setProduct($this->getProduct());
                        $block->setTemplate('Purchase/Product/Edit/Tab/SupplyNeedsSummary.phtml');
                        echo $block->toHtml();
        	?>
        </td>
    </tr>
</table>


<script>
    toggleFieldFromCombo('stocks[use_config_manage_stock]', 'stocks[manage_stock]');
    toggleFieldFromCombo('stocks[use_config_backorders]', 'stocks[backorders]');
</script>

<?php if ($manageStocks): ?>

                                    <div class="entry-edit-head">
                                        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Stocks'); ?></h4>
                                    </div>
                                    <div class="entry-edit">
                                        <div class="grid">
        <?php
                                    //display advanced stock stocks grid
                                    $block = $this->getLayout()->createBlock('AdvancedStock/Product_Stocks');
                                    $block->setProductId($this->getProduct()->getId());
                                    $block->setTemplate('AdvancedStock/Product/Stocks.phtml');
                                    echo $block->toHtml();
        ?>
                                </div>
                            </div>

                            <div class="entry-edit-head">
                                <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('New stock movement'); ?></h4>
                            </div>
                            <div class="entry-edit">
                                <div class="grid">
        <?php
                                    //display form to create a new stock movement
                                    $block = $this->getLayout()->createBlock('AdvancedStock/Product_StockMovement_New');
                                    $block->setProductId($this->getProduct()->getId());
                                    $block->setTemplate('AdvancedStock/Product/StockMovement/New.phtml');
                                    echo $block->toHtml();
        ?>
                                </div>
                            </div>

                            <p>&nbsp;</p>

                            <div class="entry-edit-head">
                                <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Stock movements'); ?></h4>
                            </div>
                            <div class="entry-edit">
    <?php
                                    //add stock movement grid
                                    echo $this->getLayout()
                                            ->createBlock('AdvancedStock/Product_Edit_Tabs_StockMovements')
                                            //->setTemplate('AdvancedStock/Product/Edit/Tab/Serials.phtml')
                                            ->setProduct($this->getProduct())
                                            ->toHtml();
    ?>
                                </div>

<?php endif; ?>
